import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import vue from '@vitejs/plugin-vue'
import topLevelAwait from 'vite-plugin-top-level-await';
export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
    topLevelAwait()
  ],
  build: {
    sourcemap: true, // 设置为 true 以在生产环境中启用 source maps
    assetsInclude: ['**/*.html'], // 添加这一行来配置 assetsInclude
    // 其他构建选项...
    target: ["chrome89", "edge89", "firefox89", "safari15"],
  },
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  // server: {
  //   proxy: {
  //     '/my': {
  //       // target: 'http://192.168.19.1:8080', // 设置代理的目标地址
  //       target: 'http://192.168.43.104:8080', // 设置代理的目标地址
  //       // target: 'http://10.65.45.144:8080', // 设置代理的目标地址
  //       // changeOrigin: true,
  //       rewrite: (path) => path.replace(/^\/api/, '') // 重写请求路径，将/api前缀移除
  //     }
  //   }
  // }
})
